import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:helloworld/tabs.dart';

class Login extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _Login();
  }
}

class _Login extends State<Login> with WidgetsBindingObserver {
  bool value = false;
  Brightness brightnessValue;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    brightnessValue = window.platformBrightness;
  }

  @override
  void didChangePlatformBrightness() {
    // TODO: implement didChangePlatformBrightness
    super.didChangePlatformBrightness();
    setState(() {
      brightnessValue = window.platformBrightness;
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          CircleAvatar(
            backgroundImage: NetworkImage(
                "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2403972683,323210450&fm=11&gp=0.jpg"),
            // backgroundColor: Colors.blueGrey
            radius: 40,
            // child: Text("奶呆记账",
            //     style: TextStyle(
            //         decoration: TextDecoration.none,
            //         fontSize: 18,
            //         color: Colors.white)),
          ),
          SizedBox(
            height: 10,
          ),
          Container(
              margin: EdgeInsets.all(8.0),
              padding: EdgeInsets.all(8.0),
              child: TextField(
                decoration: InputDecoration(
                    border: InputBorder.none, hintText: "请输入用户名"),
              ),
              decoration: BoxDecoration(
                  color: Colors.grey[200],
                  border: Border.all(color: Colors.grey[300]),
                  borderRadius: BorderRadius.circular(8))),
          SizedBox(
            height: 10,
          ),
          Container(
              margin: EdgeInsets.all(8.0),
              padding: EdgeInsets.all(8.0),
              child: TextField(
                obscureText: true,
                decoration: InputDecoration(
                    border: InputBorder.none, hintText: "请输入密码"),
              ),
              decoration: BoxDecoration(
                  color: Colors.grey[200],
                  border: Border.all(color: Colors.grey[300]),
                  borderRadius: BorderRadius.circular(8))),
          SizedBox(
            height: 8,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              FlatButton(
                onPressed: () {},
                child: Text("忘记密码"),
              ),
              Row(
                children: <Widget>[
                  Checkbox(
                    onChanged: (bool value) {
                      if (this.value) {
                        setState(() {
                          this.value = false;
                        });
                      } else {
                        setState(() {
                          this.value = true;
                        });
                      }
                    },
                    value: this.value,
                  ),
                  Text(
                    "记住密码",
                    style: TextStyle(color: Colors.black),
                  ),
                ],
              ),
              FlatButton(
                onPressed: () {
                  Navigator.of(context).pushNamed("/register");
                },
                child: Text("用户注册"),
              ),
            ],
          ),
          SizedBox(
            height: 16,
          ),
          FlatButton(
            onPressed: () {
              Navigator.of(context).pop();
              Navigator.of(context).pushAndRemoveUntil(
                  new MaterialPageRoute(
                      builder: (context) => new Tabs(index: 0)),
                  (route) => route == null);
            },
            child: CircleAvatar(
              radius: 40,
              child: Icon(Icons.arrow_forward),
            ),
          )
        ],
      ),
    );
  }
}
